% File: testbench_softdec.m
% -------------------------
% This script tests i/o characteristic of soft decision.

clear all
close all

% dbstop in softdec at 56

M_mod    = 4; % QPSK
nsymb    = 2048;
Cr       = 1;
sf       = 1;
symb_tmp = modulate(modem.qammod(M_mod),(0: M_mod-1));
symb_pow = mean(abs(symb_tmp).^2);
alpha_i  = sort(unique(real(symb_tmp)));
alpha_i_size = length(alpha_i);
alpha_i_mat  = repmat(alpha_i,nsymb,1);
alpha_q  = sort(unique(imag(symb_tmp)));
alpha_q_size = length(alpha_q);
alpha_q_mat  = repmat(alpha_q,nsymb,1);

% snr_in = [7.5614   16.4235   18.1919   18.2435   18.2499
%    10.9621   28.0652   28.9376   28.9447   28.9455
%    15.8123   45.7001   45.8760   45.8766   45.8766
%    22.6571   72.6961   72.7095   72.7095   72.7095
%    32.2307  115.2365  115.2368  115.2368  115.2368]';
% snr_in = [11.34 18.25 28.9];
numTrials = 10000;
Eb_N0  = [10 12 14];
snr_in = Eb_N0 + 10*log10(Cr*log2(M_mod)) - 10*log10(sf);

softdec

% End of script.